{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
					<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">置顶卡名称：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="name"   name="name" class="form-control" placeholder="请输入名称"  >
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">置顶卡天数：</label>
						<div class="col-sm-9">
							<input type="number" autocomplete="off" id="day"   name="day" class="form-control" placeholder="请输入天数"  >
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">置顶卡售价：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="price"   name="price" class="form-control" placeholder="请输入价格"  >
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">置顶卡权重：</label>
						<div class="col-sm-9">
							<input type="number" autocomplete="off" id="sort"   name="sort" class="form-control" placeholder="请输入权重"  >
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">置顶卡状态：</label>
						<div class="col-sm-9">
							<input name="status" value="1" type="radio" checked  title="开启">
							<input name="status" value="0" type="radio"    title="关闭">
						</div>
					</div>
					<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.add()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
	layui.use(['form'],function(){});
	laydate.render({elem: '#createtime',type: 'datetime',trigger:'click'});
	laydate.render({elem: '#expiretime',type: 'datetime',trigger:'click'});
	var CodeInfoDlg = {
		CodeInfoData: {},
		validateFields: {
			status: {
				validators: {
					notEmpty: {
						message: '状态不能为空'
					},
				}
			},
		}
	}

	CodeInfoDlg.collectData = function () {
		this.set('name').set('day').set('price').set('sort');
	};


	CodeInfoDlg.add = function () {
		this.clearData();
		this.collectData();
		if (!this.validate()) {
			return;
		}
		var status = $("input[name = 'status']:checked").val();
		var ajax = new $ax(Feng.ctxPath + "/ZhTopCard/add", function (data) {
			if ('00' === data.status) {
				Feng.success(data.msg,1000);
				window.parent.CodeGoods.table.refresh();
				CodeInfoDlg.close();
			} else {
				Feng.error(data.msg + "！",1000);
			}
		})
		ajax.set('status',status);
		ajax.set(this.CodeInfoData);
		ajax.start();
	};

</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
